For this project we are going to need to index squares on the board. Thus, its probably a good idea to write some helper functions. For example:
In future we will be able to use these functions inside other functions. This will hopefully save a bit of time and avoid a few bugs!
In [1]:
def test():
"""
Write your tests here...
Example:
>>> 1 + 1
2
"""
import doctest
doctest.testmod()
print("TESTING COMPLETE... if you see nothing, (other than this message) that means all tests passed.")
In [ ]:
def get_square(x, y, board):
"""
This function takes a board and returns the value at that square(x,y).
"""
# Your code here.
pass
def set_square(x, y, new_val, board):
"""
This function indexes into the given board at position (x, y).
We then change that value to new_val. Returns nothing.
"""
# Your code here.
pass
# Runing the tests...
test()
# Note if you recieve an error message saying test_board not found
# try hitting the run button on the test_board cell and try again.